package br.com.quad.bean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
public class VeiculoInformacaoAdicional {

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int codigoVeiculoInformacaoAdicional;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "codigoVeiculo", insertable = true, updatable = true, nullable = false)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private Veiculo veiculo;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "codigoInformacaoAdicional", insertable = true, updatable = true, nullable = false)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)
	private InformacaoAdicional informacaoAdicional;

	@Column	(length = 20)
	private String valor;

	public VeiculoInformacaoAdicional() {
	}

	public int getCodigoVeiculoInformacaoAdicional() {
		return codigoVeiculoInformacaoAdicional;
	}

	public void setCodigoVeiculoInformacaoAdicional(int codigoVeiculoInformacaoAdicional) {
		this.codigoVeiculoInformacaoAdicional = codigoVeiculoInformacaoAdicional;
	}

	public Veiculo getVeiculo() {
		return veiculo;
	}

	public void setVeiculo(Veiculo veiculo) {
		this.veiculo = veiculo;
	}

	public InformacaoAdicional getInformacaoAdicional() {
		return informacaoAdicional;
	}

	public void setInformacaoAdicional(InformacaoAdicional informacaoAdicional) {
		this.informacaoAdicional = informacaoAdicional;
	}

	public String getValor() {
		return valor;
	}

	public void setValor(String valor) {
		this.valor = valor;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + codigoVeiculoInformacaoAdicional;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		VeiculoInformacaoAdicional other = (VeiculoInformacaoAdicional) obj;
		if (codigoVeiculoInformacaoAdicional != other.codigoVeiculoInformacaoAdicional)
			return false;
		return true;
	}
}
